package com.mikao.utils;



import com.mikao.dto.vo.DateDto;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author kenny
 */
public class DateCheckUtil {

    public static DateDto getFormatDate(String dateRangePicker) throws ParseException {
        Date start = null;
        Date end = null;
        String[] time = dateRangePicker.split(" - ");
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        start = simpleDateFormat.parse(time[0]);
        end = simpleDateFormat.parse(time[1]);
        long time1 = start.getTime();
        long time2 = end.getTime();
        if (time1 == time2) {
            end.setTime(time2 + 86400000 - 1);
        }
        DateDto dateDto = new DateDto();
        dateDto.setEndTime(end);
        dateDto.setStartTime(start);
        return dateDto;
    }
}
